<?php

class Skjb_Search_Xapian_TermGenerator
{
    public $_cPtr=null;

    function __construct() {
        $this->_cPtr=new_TermGenerator();
    }

    function set_stemmer($stemmer) {
        TermGenerator_set_stemmer($this->_cPtr,$stemmer);
    }

    function set_stopper($stop=null) {
        TermGenerator_set_stopper($this->_cPtr,$stop);
    }

    function set_document($doc) {
        TermGenerator_set_document($this->_cPtr,$doc);
    }

    function get_document() {
        $r=TermGenerator_get_document($this->_cPtr);
        return is_resource($r) ? new Skjb_Search_Xapian_Document($r) : $r;
    }

    function set_database($db) {
        TermGenerator_set_database($this->_cPtr,$db);
    }

    const FLAG_SPELLING = 128;

    function set_flags($toggle,$mask=null) {
        switch (func_num_args()) {
        case 1: $r=TermGenerator_set_flags($this->_cPtr,$toggle); break;
        default: $r=TermGenerator_set_flags($this->_cPtr,$toggle,$mask);
        }
        return $r;
    }

    function index_text($text,$weight=1,$prefix=null) {
        switch (func_num_args()) {
        case 1: case 2: TermGenerator_index_text($this->_cPtr,$text,$weight); break;
        default: TermGenerator_index_text($this->_cPtr,$text,$weight,$prefix);
        }
    }

    function index_text_without_positions($text,$weight=1,$prefix=null) {
        switch (func_num_args()) {
        case 1: case 2: TermGenerator_index_text_without_positions($this->_cPtr,$text,$weight); break;
        default: TermGenerator_index_text_without_positions($this->_cPtr,$text,$weight,$prefix);
        }
    }

    function increase_termpos($delta=100) {
        TermGenerator_increase_termpos($this->_cPtr,$delta);
    }

    function get_termpos() {
        return TermGenerator_get_termpos($this->_cPtr);
    }

    function set_termpos($termpos) {
        TermGenerator_set_termpos($this->_cPtr,$termpos);
    }

    function get_description() {
        return TermGenerator_get_description($this->_cPtr);
    }
}